<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        body{
            text-align: center;
            background-image: url("imgs/bg.jpg");
            margin: 0;/*去掉自带外边距*/
            background-size: cover;/*cove  把背景图片设置为封面  设置之后  背景图片 不会随着浏览器缩放而缩放 会自动填充 */
            background-repeat: no-repeat;/*背景图片不重复*/
        }
        h1{
            font-size: 72px;
            color: #0096dc;
            margin-bottom: 0;
        }
        h2 {
            font-size: 32px;
            color: #0096dc;
            margin-bottom: 0;
        }
    </style>
</head>
<body>
<div id="app">
    <h1>欢迎来到酷鲨停车场</h1>
    <img src="imgs/shark.png">
    <h2>CoolSharkParking</h2>
    <el-card style="width: 600px;height: 370px;margin: 0 auto;
    background-color: rgba(255,255,255,0.3)">
        <!--label-width设置文本所占的宽度如果不设置,文本单独显示一行-->
        <el-form label-width="60px" style="width: 400px;margin: 50px auto">
            <el-form-item label="用户名">
                <el-input type="text" v-model="user.username" placeholder="请输入用户名"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="user.password" placeholder="请输入密码"></el-input>
            </el-form-item>
            <el-form-item label="手机号">
                <el-input type="phone" v-model="user.phone" placeholder="请输入手机号"></el-input>
            </el-form-item>
            <el-form-item style="position: relative;right: 25px">
                <template>
                    <el-radio v-model="user.sex" label="1">男</el-radio>
                    <el-radio v-model="user.sex" label="2">女</el-radio>
                </template>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" style="position: relative;right: 30px" @click="reg()">注册</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
                user:{
                    username:"",
                    password:"",
                    sex:"",
                    phone:""
                }

            }
        },
        methods:{
            reg(){
                axios.post("/user/reg",v.user).then(function (response) {
                    if (response.data==1){
                        alert("注册成功")
                    }else {
                        alert("注册失败")
                    }
                })
            }
        }
    })
</script>
</html>